package com.xiaoc.bulldozer.springboot.config.job;

import com.google.common.collect.Maps;
import com.xc.framework.common.job.OneMinuteJobService;
import com.xc.framework.common.job.OneMinuteJobServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.Map;

@Configuration
public class OneMinuteJobConfig {

    @Resource(name = "commonConfigService")
    private OneMinuteJobService commonConfigService;

    @Bean(name = "oneMinuteJobService")
    public OneMinuteJobService oneMinuteJobService() throws Throwable {

        OneMinuteJobServiceImpl oneMinuteJobService = new OneMinuteJobServiceImpl();
        Map<String, OneMinuteJobService> oneMinuteJobMap = Maps.newLinkedHashMap();
        oneMinuteJobMap.put("commonConfigService", commonConfigService);
        oneMinuteJobService.setOneMinuteJobMap(oneMinuteJobMap);
        oneMinuteJobService.refreshCacheData();

        return oneMinuteJobService;
    }
}
